package com.example.myapplication;

import android.os.Handler;
import android.os.Message;
import android.util.Log;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class MyThread extends Thread{
    @Override
    public void run() {
        try {
            URL url = new URL("https://www.wanandroid.com/user/register");
            HttpURLConnection coon = (HttpURLConnection) url.openConnection();
            coon.setRequestMethod("POST");
            coon.setConnectTimeout(5000);
            String data = "username=gdq666" + "&password=gdq821821" + "&repassword=gdq821821";
            coon.setDoOutput(true);
            OutputStream out = coon.getOutputStream();
            out.write(data.getBytes());
            if (coon.getResponseCode() == 200){
                System.out.println("访问成功！");
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
